home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3s / vprintf.z / vprintf
Encoding:
Text File  |  2001-04-17  |  4.8 KB  |  133 lines

  1.  
  2.  
  3.  
  4. VVVVPPPPRRRRIIIINNNNTTTTFFFF((((3333SSSS))))                                                        VVVVPPPPRRRRIIIINNNNTTTTFFFF((((3333SSSS))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      vprintf, vfprintf, vsnprintf, vsprintf - print formatted output of a
  10.      variable argument list
  11.  
  12. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.      ####iiiinnnncccclllluuuuddddeeee <<<<ssssttttddddaaaarrrrgggg....hhhh>>>>
  14.      ####iiiinnnncccclllluuuuddddeeee <<<<ssssttttddddiiiioooo....hhhh>>>>
  15.  
  16.      iiiinnnntttt vvvvpppprrrriiiinnnnttttffff ((((ccccoooonnnnsssstttt cccchhhhaaaarrrr ****ffffoooorrrrmmmmaaaatttt,,,, vvvvaaaa____lllliiiisssstttt aaaarrrrgggg))));;;;
  17.  
  18.      iiiinnnntttt vvvvffffpppprrrriiiinnnnttttffff ((((FFFFIIIILLLLEEEE ****ssssttttrrrreeeeaaaammmm,,,, ccccoooonnnnsssstttt cccchhhhaaaarrrr ****ffffoooorrrrmmmmaaaatttt,,,, vvvvaaaa____lllliiiisssstttt aaaarrrrgggg))));;;;
  19.  
  20.      iiiinnnntttt vvvvssssnnnnpppprrrriiiinnnnttttffff ((((cccchhhhaaaarrrr ****ssss,,,, ssssiiiizzzzeeee____tttt lllleeeennnn,,,, ccccoooonnnnsssstttt cccchhhhaaaarrrr ****ffffoooorrrrmmmmaaaatttt,,,, vvvvaaaa____lllliiiisssstttt aaaarrrrgggg))));;;;
  21.  
  22.      iiiinnnntttt vvvvsssspppprrrriiiinnnnttttffff ((((cccchhhhaaaarrrr ****ssss,,,, ccccoooonnnnsssstttt cccchhhhaaaarrrr ****ffffoooorrrrmmmmaaaatttt,,,, vvvvaaaa____lllliiiisssstttt aaaarrrrgggg))));;;;
  23.  
  24. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  25.      _v_p_r_i_n_t_f, _v_f_p_r_i_n_t_f, _v_s_n_p_r_i_n_t_f, and _v_s_p_r_i_n_t_f are the same as _p_r_i_n_t_f,
  26.      _f_p_r_i_n_t_f, _s_n_p_r_i_n_t_f, and _s_p_r_i_n_t_f respectively, except that instead of being
  27.      called with a variable number of arguments, they are called with an
  28.      argument list, _a_r_g, as defined by _s_t_d_a_r_g(5).  The _a_r_g parameter must be
  29.      initialized by the _v_a__s_t_a_r_t macro (and possibly subsequent _v_a__a_r_g calls).
  30.      The _v_p_r_i_n_t_f, _v_f_p_r_i_n_t_f, _v_s_n_p_r_i_n_t_f, and _v_s_p_r_i_n_t_f functions do not invoke
  31.      the _v_a__e_n_d macro.
  32.  
  33. EEEEXXXXAAAAMMMMPPPPLLLLEEEE
  34.      The following demonstrates the use of _v_f_p_r_i_n_t_f to write an error routine.
  35.  
  36.      The _s_t_d_a_r_g._h header file defines the type _v_a__l_i_s_t and a set of macros for
  37.      advancing through a list of arguments whose number and types may vary.
  38.      The argument _a_p to the vprint family of routines is of type _v_a__l_i_s_t.
  39.      This argument is used with the _s_t_d_a_r_g._h header file macros _v_a__s_t_a_r_t,
  40.      _v_a__a_r_g and _v_a__e_n_d [see _v_a__s_t_a_r_t, _v_a__a_r_g, and _v_a__e_n_d in _s_t_d_a_r_g(5)].
  41.  
  42.      #include <stdio.h>
  43.      #include <stdarg.h>
  44.  
  45.      /*
  46.       *   error should be called as:
  47.       *   error(function_name, format, arg1, arg2 ...);
  48.       */
  49.      void
  50.      error(char *function_name, char *format, ...)
  51.      {
  52.           va_list args;
  53.  
  54.           va_start(args, format);
  55.           /* print out name of function causing error */
  56.           fprintf(stderr, "ERROR in %s: ", function_name);
  57.           /* print out remainder of message */
  58.           vfprintf(stderr, format, args);
  59.           va_end(args);
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. VVVVPPPPRRRRIIIINNNNTTTTFFFF((((3333SSSS))))                                                        VVVVPPPPRRRRIIIINNNNTTTTFFFF((((3333SSSS))))
  71.  
  72.  
  73.  
  74.      }
  75.  
  76. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  77.      printf(3S), stdarg(5).
  78.  
  79. DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  80.      _v_p_r_i_n_t_f, _v_f_p_r_i_n_t_f, _v_s_n_p_r_i_n_t_f, and _v_s_p_r_i_n_t_f return the number of
  81.      characters transmitted, or return -_1 if an error was encountered.
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.